#region Header
//=============================================================================
//                          GShield (Game Shield)
//=============================================================================
//
// Original Programmer: Shawn Jackson
// Company: WaveTech Digital Technologies, Inc. (http://www.wtdt.com)
// Copyright: (c) 2006 WaveTech Digital Technologies, Inc. All Rights Reserved.
// Assembly: Library
// Code File Name: RatingsPolicy.cs
// Code File Date: 10/22/2006
//
// Code File Info: Class defining a RatingsPolicy object
//=============================================================================
/*
 * UPDATES
 * -------
 *			ShawnJ 8/7/2007 (0.9.5.x): Code Commenting.
 */
#endregion Header

#region License
/*
  GShield - Game Shield
  Copyright (C) 2006-2007 WaveTech Digital Technologies, Inc.
                                http://www.wtdt.com

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
#endregion License

#region Includes
using System;
using System.Text;
#endregion Includes

namespace WaveTech.GShield.Library.Objects
{
    /*
	/// <summary>
	/// Defines a Ratings Policy object detailing the users name 
	/// and allowed (playable) ESRB ratings.
	/// </summary>
	[Serializable]
  public class RatingsPolicy
	{
		#region Private Members
		private int? m_id;
		private string m_userName;
		private bool? m_allowEC;
		private bool? m_allowE;
		private bool? m_allow10P;
		private bool? m_allowT;
		private bool? m_allowM;
		private bool? m_allowAO;
		private bool? m_allowRP;
		private bool? m_allowUnknown;
		private string m_hash;
		private DateTime? m_timestamp;
		#endregion Private Members

		#region Public Properties
		/// <summary>
		/// Primary Identifier for this policy
		/// </summary>
		public int? Id
    {
			get { return m_id; }
			set { m_id = value; }
    }

		/// <summary>
		/// Username this policy is applied to
		/// </summary>
    public string UserName
    {
			get { return m_userName; }
			set { m_userName = value; }
    }

		/// <summary>
		/// Allow Early Childhood Games
		/// </summary>
    public bool? AllowEC
    {
			get { return m_allowEC; }
			set { m_allowEC = value; }
    }

		/// <summary>
		/// Allow Everyone games
		/// </summary>
    public bool? AllowE
    {
			get { return m_allowE; }
			set { m_allowE = value; }
    }

		/// <summary>
		/// Allow 10+ Games
		/// </summary>
    public bool? Allow10P
    {
			get { return m_allow10P; }
			set { m_allow10P = value; }
    }

		/// <summary>
		/// Allow Teen games
		/// </summary>
    public bool? AllowT
    {
			get { return m_allowT; }
			set { m_allowT = value; }
    }

		/// <summary>
		/// Allow Mature games
		/// </summary>
    public bool? AllowM
    {
			get { return m_allowM; }
			set { m_allowM = value; }
    }

		/// <summary>
		/// Allow Adults Only games
		/// </summary>
    public bool? AllowAO
    {
			get { return m_allowAO; }
			set { m_allowAO = value; }
    }
		
		/// <summary>
		/// Allow Ratings Pending games
		/// </summary>
    public bool? AllowRP
    {
			get { return m_allowRP; }
			set { m_allowRP = value; }
    }

		/// <summary>
		/// Allow unknown games. Games that can't
		/// get the rating from the ESRB.
		/// </summary>
    public bool? AllowUnknown
    {
			get { return m_allowUnknown; }
			set { m_allowUnknown = value; }
    }

		/// <summary>
		/// Timestamp of the policy
		/// </summary>
    public DateTime? Timestamp
    {
			get { return m_timestamp; }
			set { m_timestamp = value; }
    }

		/// <summary>
		/// Saved hash for the critical members
		/// </summary>
    public string Hash
    {
			get { return m_hash; }
			set { m_hash = value; }
    }
    #endregion Public Properties

    #region Public Functions
		/// <summary>
		/// Computes the current hash for critical object members
		/// </summary>
		/// <returns>Hash as a string</returns>
    public string ComputeHash()
    {
      StringBuilder newHash = new StringBuilder();

			if (m_userName != null)
				newHash.Append(m_userName);

			if (m_allowEC != null)
				newHash.Append(m_allowEC.Value.ToString());

			if (m_allowE != null)
				newHash.Append(m_allowE.Value.ToString());

			if (m_allow10P != null)
				newHash.Append(m_allow10P.Value.ToString());

			if (m_allowT != null)
				newHash.Append(m_allowT.Value.ToString());

			if (m_allowM != null)
				newHash.Append(m_allowM.Value.ToString());

			if (m_allowAO != null)
				newHash.Append(m_allowAO.Value.ToString());

			if (m_allowRP != null)
				newHash.Append(m_allowRP.Value.ToString());

			if (m_allowUnknown != null)
				newHash.Append(m_allowUnknown.Value.ToString());

      return Common.Hash.ComputeHash(newHash.ToString(), "SHA256", null);
    }

		/// <summary>
		/// Checks to ensure the computed hash matches the current
		/// hash of critical object members.
		/// </summary>
		/// <returns>True if the hashs match, otherwise false.</returns>
    public bool IsHashValid()
    {
			if (m_hash == null)
        return false;

			return Common.Hash.VerifyHash(ComputeHash(), "SHA256", m_hash);
    }
    #endregion Public Functions
  }
    */
}